var a = getApp();

Page({
    data: {
        active: 0,
        tabsArr: [ {
            name: "预期佣金",
            code: "expect"
        }, {
            name: "未结算佣金",
            code: "unsettle"
        }, {
            name: "已结算佣金",
            code: "settle"
        }, {
            name: "未提现佣金",
            code: "unwithdraw"
        }, {
            name: "已提现佣金",
            code: "withdraw"
        }, {
            name: "已失效佣金",
            code: "disabled"
        } ],
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1
    },
    onLoad: function(a) {
        console.log(a.active), a.active && this.setData({
            active: parseInt(a.active)
        }), this.getListData();
    },
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            networkLoading: !1
        });
    },
    getListData: function() {
        var t = this;
        this.initData();
        var e = this.data, o = e.tabsArr, i = e.active, n = e.page, s = {
            amount_type: o[i].code,
            page: n
        }, d = a.getNetAddresss("plugin.live-install.frontend.worker.workerAmountList");
        a._postNetWork({
            url: d,
            data: s,
            success: function(e) {
                var o = e.data;
                if (1 != o.result) return a.tips(o.msg);
                t.data.total_page = o.data.last_page, t.data.total_page || (t.data.total_page = 0), 
                t.setData({
                    listData: o.data.data,
                    networkLoading: !0
                }), console.log(o);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = this.data, o = e.tabsArr, i = e.active, n = e.page, s = {
                amount_type: o[i].code,
                page: n
            }, d = a.getNetAddresss("plugin.live-install.frontend.worker.workerAmountList");
            a._postNetWork({
                url: d,
                data: s,
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var o = t.data.listData.concat(e.data.data);
                        t.setData({
                            listData: o
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    bindChangeActive: function(a) {
        this.setData({
            active: a.detail.index
        }), this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});